﻿using System;
using System.Collections.Generic;
using SinBiota.Model.Business.PersistenceServices.Interfaces;
using SinBiota.Model.Entities;
using SinBiota.Model.Persistence.Repositories.Interfaces;

namespace SinBiota.Model.Business.PersistenceServices.Implementation
{
    public class LocationPersistenceServices : ILocationPersistenceServices
    {
        private readonly ILocationRepository _locationRepository;
        private readonly IMunicipalityRepository _municipalityRepository;
        private readonly IDrainageBasinRepository _drainageBasinRepository;
        private readonly IConservationUnitRepository _conservationUnitRepository;

        public LocationPersistenceServices(ILocationRepository locationRepository, IMunicipalityRepository municipalityRepository, IDrainageBasinRepository drainageBasinRepository, IConservationUnitRepository conservationUnitRepository)
        {
            _locationRepository = locationRepository;
            _conservationUnitRepository = conservationUnitRepository;
            _drainageBasinRepository = drainageBasinRepository;
            _municipalityRepository = municipalityRepository;
        }

        public Location FindById(int id)
        {
            return _locationRepository.FindById(id);
        }

        public IList<Location> FindAll()
        {
            return _locationRepository.FindAll();
        }

        public void Delete(Location location)
        {
            _locationRepository.Delete(location);
        }

        public void DeleteById(int id)
        {
            Delete(FindById(id));
        }
        public void Save(Location location)
        {
            _locationRepository.Save(location);
        }

        public void Update(Location location)
        {
            _locationRepository.Update(location);
        }

        public Municipality FindMunicipalityById(int id)
        {
            return _municipalityRepository.FindById(id);
        }

        public DrainageBasin FindDrainageBasinById(int id)
        {
            return _drainageBasinRepository.FindById(id);
        }

        public ConservationUnit FindConservationUnitById(int id)
        {
            return _conservationUnitRepository.FindById(id);
        }
    }
}